package games.tankwars.behaviors;
import vooga.core.AbstractLevel;
import vooga.entities.Entity;


/**
 * @author Robert C. Duvall
 */
public class FollowPrecise extends vooga.behaviors.AbstractBehavior
{
    private games.tankwars.entities.Tank myTank;
    private AbstractLevel myLevel;
//    private int myTimer;
    
    public FollowPrecise (games.tankwars.entities.Tank tank, AbstractLevel level)
    {
        myTank = tank;
        myLevel=level;
//        myTimer=0;
    }


	@Override
	public void step(Entity target) {
		// TODO Auto-generated method stub
		
		double dx=myTank.getCenter().getX()-target.getCenter().getX();
		double dy=myTank.getCenter().getY()-target.getCenter().getY();
		
		double heading = Math.toDegrees(Math.atan(dy/dx));

		if (myTank.isVisible())
		{
			if (dx<0)
				target.setHeading(heading+180);
			else
			target.setHeading(heading);
			target.translate(dx/30, dy/30);
		}
	}
}
